package com.zr.quotation.service.impl;

import com.zr.Inquiry.pojo.InquiryTotalVo;
import com.zr.quotation.mapper.QuotationMapper;
import com.zr.quotation.pojo.QuotationSelectVo;
import com.zr.quotation.pojo.QuotationVo;
import com.zr.quotation.service.QuotationService;
import com.zr.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName QuotationServiceImpl
 * @Description TODO
 * @Author xiaowei
 * @Date 2020/1/2 10:20
 * @Version 1.0
 */
@Service
public class QuotationServiceImpl implements QuotationService {
    @Autowired
    private QuotationMapper quotationMapper;

    @Override
    public ResultVo searchPre(QuotationSelectVo quotationSelectVo) {
        AllRecords allRecords= new AllRecords();
        List<QuotationVo>quotationVoList=quotationMapper.queryData(quotationSelectVo);
        for (QuotationVo quotationVo : quotationVoList) {
            quotationVo.setCurrencyCodeName(CurrencyCodeEnum.getName(quotationVo.getCurrencyCode()));
        }
        //当前页
        //条件查询总条数
        int count=quotationMapper.queryCount(quotationSelectVo);
        //查询数据
        allRecords.setPageIndex(quotationSelectVo.getPageIndex());
        //每页显示条数
        allRecords.setPageSize(quotationSelectVo.getPageSize());
        //总数量
        allRecords.setTotalNumber(count);
        //分页的列表数据
        allRecords.setDataList(quotationVoList);
        allRecords.resetTotalNumber(count);
        return ResultBuilderVo.success(allRecords);
    }
}
